package com.lottery.im.module.service.ui;

import android.annotation.SuppressLint;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.lottery.im.api.Api;
import com.lottery.im.api.result.entity.integral.ExchangeResult;
import com.lottery.im.databinding.ExchangeResultBinding;

import com.lottery.im.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class ExchangeResultSubFragment extends Fragment {

  private ExchangeResult mExchangeResult;

  public ExchangeResultSubFragment() {
    // Required empty public constructor
  }

  @SuppressLint("ValidFragment") public ExchangeResultSubFragment(
      ExchangeResult exchangeResult) {
    mExchangeResult = exchangeResult;
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    ExchangeResultBinding binding =
        DataBindingUtil.inflate(inflater, R.layout.fragment_exchange_result_sub, container, false);

    binding.setExchangeResult(mExchangeResult);

    Glide.with(getActivity())
        .load(Api.BASEADDRESS+mExchangeResult.getImg())
        .apply(new RequestOptions()
            .placeholder(R.drawable.icon_conversation_de)
            .error(R.drawable.icon_conversation_de)
            .override(200,200)
            .fitCenter())
        .into(binding.imageView);
    return binding.getRoot();
  }
}
